<?php
namespace home\Model;
use Think\Model;
class BusinessCardModel extends Model{

    public function send($from,$to){
        $business_card['main_user_id'] = $from;
        $business_card['give_user_id'] = $to;
        $count = M('business_card')
            ->where('main_user_id = '.$business_card['main_user_id'].' and give_user_id ='.$business_card['give_user_id'])
            ->count();
        if ($count == 0){
            M('business_card')->add($business_card);
        }

    }
    

    public function admin_send($user_id)
    {
        $admin = M('user')->where('id < 0')->select();
        foreach ($admin as $key => $value) {
            $this->send($admin[$key]['id'],$user_id);
        }
    }
}